<?php $this->widget('bootstrap.widgets.BootAlert'); ?>
<div class="span3 well">
<h3>Городские здания</h3>
	<ul class="nav nav-list">
	<?php
		foreach($buildings as $b)
		{
			$upd_price = '';
			foreach($b['upd_price'] as $key => $val){
				$upd_price .= $key.' : '.$val.' ';
			}
			
			echo '<li class="nav-header"><span>'.$b['label'].'<span style="float:right">'.
				$this->widget('bootstrap.widgets.BootButton', array(
					'label'=>'+',
					'type'=>'danger',
					'size' => 'small',
					'url' => $this->createUrl('building/levelUp', array('id'=>$b['id'])),
					'htmlOptions'=>array('data-title'=>'Увеличить уровень', 'data-content'=>'Для поднятия уровня здания требуется<br />'.$upd_price, 'rel'=>'popover'),
				),true)
			.'</span></span></li>';
		}
	?>
    </ul>

	<p style="height:20px;"> </p>
	
	<?php $this->beginWidget('bootstrap.widgets.BootModal', array('id'=>'myModal')); ?>

	<?php /** @var BootActiveForm $form */
		$form = $this->beginWidget('bootstrap.widgets.BootActiveForm', array(
			'id'=>'buildForm',
			'htmlOptions'=>array('class'=>'well'),
			'action' => $this->createUrl('building/addBuilding')
		)); 
	?>
	
		<div class="modal-header">
			<a class="close" data-dismiss="modal">&times;</a>
			<h3>Список зданий</h3>
		</div>
		 
		<div class="modal-body">
			<?php 
			
			echo $form->dropDownListRow($newBuild, 'id_building', $bt, array(
												'prompt'=>'Выберите',
												'ajax' => array(
													'type' => 'POST', 
													'url' => $this->createUrl('building/getResourceBuilding'),
													'dataType'=>'json',
													'data'=>array('id_building'=>'js:this.value'),  
													'success'=>'function(data) {
														
														var str = "";
														for(var i in data.label)
														{
															str += data.label[i];
														}
														
														$("#id_lab").html(str);
													}'
													)
												)
			
			); 
			
			
			
			?>
			<p id="id_lab" ></p>
		</div>
		 
		<div class="modal-footer">
			<?php $this->widget('bootstrap.widgets.BootButton', array('buttonType'=>'submit', 'icon'=>'ok', 'label'=>'Построить')); ?>
				
			<?php $this->widget('bootstrap.widgets.BootButton', array(
						'label'=>'Закрыть',
						'url'=>'#',
						'htmlOptions'=>array('data-dismiss'=>'modal'),
					)); 
			?>
		</div>
		
	<?php $this->endWidget(); ?>
 
	<?php $this->endWidget(); ?>
	
	
	<?php $this->widget('bootstrap.widgets.BootButton', array(
    'label'=>'Добавить здание',
    'url'=>'#myModal',
    'type'=>'success',
	'size'=>'small',
    'htmlOptions'=>array('data-toggle'=>'modal'),
)); ?>
</div>